<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplierId" label="供应商主表id">
          <a-input placeholder="请输入供应商主表id" v-model="model.supplierId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessNature" label="经营性质">
          <a-input placeholder="请输入经营性质" v-model="model.businessNature" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="industry" label="行业">
          <a-input placeholder="请输入行业" v-model="model.industry" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enterpriseType" label="企业类型">
          <a-input placeholder="请输入企业类型" v-model="model.enterpriseType" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registeredCapital" label="注册资本">
          <a-input placeholder="请输入注册资本" v-model="model.registeredCapital" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgOde" label="组织机构代码">
          <a-input placeholder="请输入组织机构代码" v-model="model.orgOde" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="busCreateDate" label="成立日期">
          <a-date-picker showTime valueFormat='YYYY-MM-DD HH:mm:ss' v-model="model.busCreateDate" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="introduction" label="企业简介">
          <a-input placeholder="请输入企业简介" v-model="model.introduction" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessRange" label="经营范围">
          <a-input placeholder="请输入经营范围" v-model="model.businessRange" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="produceAddress" label="生产地址">
          <a-input placeholder="请输入生产地址" v-model="model.produceAddress" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="serviceAddress" label="服务点地址">
          <a-input placeholder="请输入服务点地址" v-model="model.serviceAddress" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="techContact" label="技术联系人">
          <a-input placeholder="请输入技术联系人" v-model="model.techContact" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="techContactPhone" label="技术联系人联系方式">
          <a-input placeholder="请输入技术联系人联系方式" v-model="model.techContactPhone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reqUnitManager" label="需求单位经办人">
          <a-input placeholder="请输入需求单位经办人" v-model="model.reqUnitManager" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reqUnitManagerPhone" label="需求单位经办人">
          <a-input placeholder="请输入需求单位经办人" v-model="model.reqUnitManagerPhone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="legalPerson" label="法人姓名">
          <a-input placeholder="请输入法人姓名" v-model="model.legalPerson" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taxNumber" label="税务登记号">
          <a-input placeholder="请输入税务登记号" v-model="model.taxNumber" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="email" label="邮箱">
          <a-input placeholder="请输入邮箱" v-model="model.email" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="telephone" label="办公电话">
          <a-input placeholder="请输入办公电话" v-model="model.telephone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fax" label="传真">
          <a-input placeholder="请输入传真" v-model="model.fax" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zipCode" label="邮编">
          <a-input placeholder="请输入邮编" v-model="model.zipCode" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registerPhone" label="注册手机">
          <a-input placeholder="请输入注册手机" v-model="model.registerPhone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phoneJson" label="其它接收短信手机（json）">
          <a-input placeholder="请输入其它接收短信手机（json）" v-model="model.phoneJson" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankNum" label="银行账号">
          <a-input placeholder="请输入银行账号" v-model="model.bankNum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankName" label="开户行">
          <a-input placeholder="请输入开户行" v-model="model.bankName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag" label="删除标识（0未删除|1已删除）">
          <a-input placeholder="请输入删除标识（0未删除|1已删除）" v-model="model.delFlag" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "MdmSupplierOtherDetailModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        delFlag:[{ required: true, message: '请输入删除标识（0未删除|1已删除）!' }],
        },
        url: {
          add: "/supplier/mdmSupplierOtherDetail/add",
          edit: "/supplier/mdmSupplierOtherDetail/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>